package com.app.controller;

import com.app.common.EducationTool;
import com.app.conf.RedisService;
import com.app.mapper.*;
import com.app.model.*;
import com.app.service.*;
import com.app.util.CommonHelp;
import com.app.util.Result;
import com.app.vo.EmploymentVo;
import com.app.vo.IndexCountVo;
import com.app.vo.SalaryAvgVo;
import com.app.vo.ValueAndNameVo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

@RestController
@Controller
public class StatController {

    @Autowired
    private RedisService redisService;
    @Autowired
    AdminUserService adminUserService;
    @Resource
    QuestionnaireInvestigationService questionnaireInvestigationService;
    @Autowired
    EnterpriseService enterpriseService;
    @Autowired
    ComRecruitersService comRecruitersService;

    @Autowired
    JobPublishService jobPublishService;
    @Autowired
    JobPublishMapper jobPublishMapper;
    @Autowired
    JobIntentionMapper jobIntentionMapper;
    @Autowired
    WorkApplyService workApplyService;

    @Autowired
    BrowseNumberService browseNumberService;

    @Autowired
    JobFairCompanyService jobFairCompanyService;
    @Autowired
    JobFairSceneService jobFairSceneService;

    @Autowired
    CustomerService customerService;



    @Autowired
    CusEducationService cusEducationService;

    @Autowired
    NewsService newsService;
    @Autowired
    ClickStatisticsService clickStatisticsService;
    @Resource
    MatchingSuccessfulMapper matchingSuccessfulMapper;
    @Autowired
    ComResumeNumberService comResumeNumberService;
    @Autowired
    ConfigMapper configMapper;
    @Autowired
    JobIntentionService jobIntentionService;
    @Autowired
    UserService userService;
    @Resource
    PositionService positionService;
    @Resource
    EnterpriseMapper enterpriseMapper;
    @Resource
    PositionMapper positionMapper;
    @Resource
    ClickStatisticsMapper clickStatisticsMapper;
    @Resource
    OpinionService opinionService;

    /**
     * 用户使用
     */
    //用户使用频率分析
    @GetMapping("/getFrequencyCount")
    public Result<Object> getFrequencyCount(HttpServletRequest request) {
        List<Integer> frequencyList = new ArrayList<>();
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        String endTime = format.format(CommonHelp.getNowTimestamp());
        String today = format.format(CommonHelp.getNowTimestamp());//今天
        Calendar calendar = Calendar.getInstance(); //得到日历
        calendar.add(Calendar.DAY_OF_MONTH, -3);
        Date beforeMonth = calendar.getTime();
        String three = format.format(beforeMonth);//3天
        Calendar calendar2 = Calendar.getInstance(); //得到日历
        calendar2.add(Calendar.DAY_OF_MONTH, -7);
        Date beforeMonth2 = calendar2.getTime();
        String seven = format.format(beforeMonth2);//7天
        Calendar calendar3 = Calendar.getInstance(); //得到日历
        calendar3.add(Calendar.DAY_OF_MONTH, -15);
        Date beforeMonth3 = calendar3.getTime();
        String fifteen = format.format(beforeMonth3);//15天
        Calendar calendar4 = Calendar.getInstance(); //得到日历
        calendar4.add(Calendar.DAY_OF_MONTH, -30);
        Date beforeMonth4 = calendar4.getTime();
        String month = format.format(beforeMonth4);//30天
        frequencyList.add(customerService.getModelCountByLoginTime(today, endTime));
        frequencyList.add(customerService.getModelCountByLoginTime(three, endTime));
        frequencyList.add(customerService.getModelCountByLoginTime(seven, endTime));
        frequencyList.add(customerService.getModelCountByLoginTime(fifteen, endTime));
        frequencyList.add(customerService.getModelCountByLoginTime(month, endTime));
        return Result.success(frequencyList);
    }
    //用户来源分析

    //各模块点击量

    //用户登录时间、频率统计
    @GetMapping("/getCusUseFrequency")
    public Result<Object> getCusUseFrequency() {
        return Result.success(clickStatisticsService.getCountList());
    }

    //近一月个人注册流程质量分析
    @GetMapping("/getCustomerQualityCount")
    public Result<Object> getCustomerQualityCount() {
        List<Integer> qualityList = new ArrayList<>();
        int intentionCount = jobIntentionService.getCountByGroup();
        int cusCount = customerService.getModelCountByNull();
        int countAll = customerService.getCountAll();
        qualityList.add(countAll);//完成注册用户数
        qualityList.add(cusCount);//注册个人信息环节留存
        qualityList.add(countAll - intentionCount - cusCount);
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < qualityList.size(); i++) {
            list.add(qualityList.get(i));
        }
        return Result.success(list);
    }

    //近一月企业注册流程质量分析
    @GetMapping("/getComQualityCount")
    public Result<Object> getComQualityCount() {
        List<Integer> qualityList = new ArrayList<>();
        int comCount = userService.getNosRegisterCount();
        int cusCount = customerService.getModelCountByNull();
        int noPublish = comRecruitersService.getNotPublishCount();
        qualityList.add(cusCount);//完成注册企业数
        qualityList.add(comCount);//注册企业信息环节留存
        qualityList.add(noPublish);

        int a = qualityList.get(0);
        int b = qualityList.get(1);
        int c = qualityList.get(2);
        List<Integer> list = new ArrayList<>();
        list.add(a);
        list.add(b);
        list.add(c);
        return Result.success(list);
    }
    /*PlatformOperationController
    访问趋势数据   accessTrendsData
    反馈 feedback
    小程序访问  转发 userFrequencyData
     */

    /**
     * 劳动力情况
     */
    //未就业人员意向就业岗位(TOP20)
    @GetMapping("/industrialEmploymentSituation")
    public Result<Object> industrialEmploymentSituation() {
        List<QuestionnaireInvestigationModel> unemployedPost = questionnaireInvestigationService.unemployedPost();
        List<ValueAndNameVo> vo = new ArrayList<>();
        List<QuestionnaireInvestigationModel> collect = unemployedPost.stream().limit(20).collect(Collectors.toList());
        for (
                int i = 0; i < collect.size(); i++) {
            if (collect.get(i).getId() != null) {
                ConfigModel configModel = configMapper.selectById(collect.get(i).getId());
                if (configModel != null) {
                    ValueAndNameVo vo0 = new ValueAndNameVo();
                    vo0.setId(i + 1);
                    vo0.setName(configModel.getName());
                    vo0.setValue(collect.get(i).getCount());
                    vo.add(vo0);
                }
            }
        }
        String[] dataY = new String[vo.size()];
        int[] dataX = new int[vo.size()];
        ValueAndNameVo valueAndNameVo = new ValueAndNameVo();
        for (int i = 0; i < vo.size(); i++) {
            dataY[i] = vo.get(i).getName();
            dataX[i] = vo.get(i).getValue();
        }
        valueAndNameVo.setDataY(dataY);
        valueAndNameVo.setDataX(dataX);
        return Result.success(valueAndNameVo);
    }

    //未就业人数分布
    @GetMapping("/Unemployed")
    private Result<Object> Unemployed() {
        Integer[] unemployed = questionnaireInvestigationService.Unemployed();
        ValueAndNameVo v1 = new ValueAndNameVo();
        int[] arr = {unemployed[0]};
        int[] arr1 = {unemployed[1]};
        v1.setArr(arr);
        v1.setArr2(arr1);
        return Result.success(v1);
    }
    //大就业信息系统登记未就业人员情况

    //农村劳动力，城镇劳动力，劳动力总数
    @GetMapping("/ruralAndCityCount")
    private Result<Object> ruralAndCityCount() {
        //农村劳动力
        Integer ruralLaborersCount = questionnaireInvestigationService.ruralLaborersCount();
        //城镇劳动力
        Integer cityCount = questionnaireInvestigationService.cityCount();
        //劳动力总数
        Integer allCount = questionnaireInvestigationService.allCount();
        ValueAndNameVo vo = new ValueAndNameVo();
        vo.setRuralLaborersCount(ruralLaborersCount);
        vo.setCityCount(cityCount);
        vo.setAllCount(allCount);
        return Result.success(vo);
    }
    //农村劳动力，城镇劳动力，劳动力总数列表
    @GetMapping("/ruralAndCityList")
    private Result<Object> ruralAndCityList(Integer type) {//0全部1农村2城市
        List<QuestionnaireInvestigationModel> questionnaireInvestigationModels = questionnaireInvestigationService.ruralAndCityList(type);
        return Result.success(questionnaireInvestigationModels);
    }
    /**
     * 就业服务
     *
     * @param request
     * @return
     */
    // 数据统计
    @GetMapping("/getAllIndexCount")
    public Result<Object> getAllIndexCount(HttpServletRequest request) {
        int enterpriseCount = comRecruitersService.getCountByGroup(null, null, 2);//企业数
        int jobCount = jobPublishService.countAll();//岗位数
        int browseCount = browseNumberService.getBrowseCount(null, null, 2);//浏览数
        int customerCount = customerService.getModelCountByTime("2023-07-14 00:00:00", null, null, 2);//人数
        int delivererCount = workApplyService.countGroup();//简历投递人
        int deliveryCount = workApplyService.countAll(null, null, 2);//简历投递量
        int intentionCount = jobIntentionService.getCountByGroup();
//        int mateCount = matchingSuccessfulMapper.selectCount();//匹配成功
        IndexCountVo vo = new IndexCountVo();
        vo.setEnterpriseCount(enterpriseCount);
        vo.setJobCount(jobCount);
        vo.setBrowseCount((browseCount));
        vo.setCustomerCount(customerCount);
        vo.setDelivererCount(delivererCount);
        vo.setDeliveryCount(deliveryCount);
//        vo.setMateCount(mateCount);
        vo.setIntentionCount(intentionCount);
        Integer[] registerCounts = {vo.getCustomerCount()};
        Integer[] intentionCounts = {vo.getIntentionCount()};
        Integer[] accessCounts = {vo.getBrowseCount()};
        Integer[] publishCounts = {vo.getJobCount()};
        vo.setRegisterCounts(registerCounts);
        vo.setIntentionCounts(intentionCounts);
        vo.setAccessCounts(accessCounts);
        vo.setPublishCounts(publishCounts);
        return Result.success(vo);
    }

    //行业供求薪资分布
    @GetMapping("/getPostSalaryAve")
    public Result<Object> getPostSalaryAve() {
        List<JobPublishModel> publishModelList = jobPublishMapper.getPostSalaryAve();
        List<JobIntentionModel> intentionModelList = jobIntentionMapper.getSalaryAvg();
        List<SalaryAvgVo> voList = new ArrayList<>();
        for (int i = 0; i < publishModelList.size(); i++) {
            SalaryAvgVo vo = new SalaryAvgVo();
            vo.setName(publishModelList.get(i).getJobTitle());
            voList.add(vo);
        }
        for (int i = 0; i < intentionModelList.size(); i++) {
            SalaryAvgVo vo = new SalaryAvgVo();
            vo.setName(intentionModelList.get(i).getJobTitle());
            voList.add(vo);
        }

        List<SalaryAvgVo> newVoList = new ArrayList<>();
        newVoList = removeDuplicationBy2For(voList);
        for (int i = 0; i < newVoList.size(); i++) {
            for (int j = 0; j < publishModelList.size(); j++) {
                if (newVoList.get(i).getName().equals(publishModelList.get(j).getJobTitle())) {
                    newVoList.get(i).setPublishSalary(publishModelList.get(j).getSumAll());
                    break;
                } else {
                    newVoList.get(i).setPublishSalary(0);

                }
            }
            for (int j = 0; j < intentionModelList.size(); j++) {
                if (newVoList.get(i).getName().equals(intentionModelList.get(j).getJobTitle())) {
                    newVoList.get(i).setIntentionSalary(intentionModelList.get(j).getSumAll());
                    break;
                } else {
                    newVoList.get(i).setIntentionSalary(0);

                }
            }
        }
        return Result.success(newVoList);
    }

    /**
     * 使用双重for循环实现List去重(有序)
     *
     * @param list
     */
    public static List removeDuplicationBy2For(List<SalaryAvgVo> list) {
        for (int i = 0; i < list.size(); i++) {
            for (int j = i + 1; j < list.size(); j++) {
                if (list.get(i).equals(list.get(j))) {
                    list.remove(j);
                }
            }
        }
        return list;
    }

    //热度排行top20
    @GetMapping("/employers")
    public Result<Object> employers(Integer type) {//type=1企业2岗位
        List<ValueAndNameVo> vo = new ArrayList<>();
        if (type != null && type == 1) {
            List<WorkApplyModel> employers = workApplyService.employers();//热门企业
            employers.sort(Comparator.comparing(WorkApplyModel::getCount).reversed());
            List<WorkApplyModel> collect = employers.stream().limit(20).collect(Collectors.toList());
            for (int i = 0; i < collect.size(); i++) {
                ValueAndNameVo vo1 = new ValueAndNameVo();
                vo1.setId(i + 1);
                vo1.setName(collect.get(i).getEnterpriseName());
                vo1.setValue(collect.get(i).getCount() * 3);
                vo.add(vo1);

            }
        }
        if (type != null && type == 2) {
            List<WorkApplyModel> post = workApplyService.post();//热门岗位
            post.sort(Comparator.comparing(WorkApplyModel::getCount).reversed());
            List<WorkApplyModel> collect = post.stream().limit(20).collect(Collectors.toList());
            for (int i = 0; i < collect.size(); i++) {
                JobPublishModel jobPublishModel = jobPublishMapper.selectById(collect.get(i).getPublishId());
                ValueAndNameVo vo1 = new ValueAndNameVo();
                vo1.setId(i + 1);
                if (jobPublishModel != null) {
                    vo1.setName(jobPublishModel.getJobTitle());
                    vo1.setValue(collect.get(i).getCount() * 3);
                    vo.add(vo1);
                }
            }
        }
        return Result.success(vo);
    }

    //求职者学历分布 饼状
    @GetMapping("/educationPie")
    public Result<Object> educationPie() {
        return Result.success(cusEducationService.educationPie());
    }

    //求职者年龄分布 饼状  16-24  25-35 35-45 45-55 55以上
    @GetMapping("/agePie")
    public Result<Object> agePie() throws ParseException {
        int[] customerModels = customerService.agePie();
        List<ValueAndNameVo> vos = new ArrayList<>();
        //16-25  25-35 35-45 45-55
        ValueAndNameVo vo = new ValueAndNameVo();
        vo.setName("16-25");
        vo.setValue(customerModels[0]);
        vos.add(vo);

        ValueAndNameVo vo1 = new ValueAndNameVo();
        vo1.setName("25-35");
        vo1.setValue(customerModels[1]);
        vos.add(vo1);

        ValueAndNameVo vo2 = new ValueAndNameVo();
        vo2.setName("35-45");
        vo2.setValue(customerModels[2]);
        vos.add(vo2);

        ValueAndNameVo vo3 = new ValueAndNameVo();
        vo3.setName("45-55");
        vo3.setValue(customerModels[3]);
        vos.add(vo3);

        ValueAndNameVo vo4 = new ValueAndNameVo();
        vo4.setName("55以上");
        vo4.setValue(customerModels[4]);
        vos.add(vo4);
        return Result.success(vos);
    }

    //求职者性别分布
    @GetMapping("/jobTypePie")
    public Result<Object> jobTypePie() {
        int[] sexCount = customerService.selectSexCount();
        int male = sexCount[0];
        int female = sexCount[1];
        List<ValueAndNameVo> vo = new ArrayList<>();
        ValueAndNameVo v = new ValueAndNameVo();
        v.setValue(male);
        v.setName("男");
        ValueAndNameVo v1 = new ValueAndNameVo();
        v1.setValue(female);
        v1.setName("女");
        vo.add(v);
        vo.add(v1);
        return Result.success(vo);
    }

    /**
     * 就地就业
     */
    //就业企业统计
    @GetMapping("/demand")
    public Result<Object> demand() {
        List<JobPublishModel> jobPublishModels = jobPublishService.selectPost();
        for (int i = 0; i < jobPublishModels.size(); i++) {
            if (jobPublishModels.get(i).getCount() == null) {
                jobPublishModels.get(i).setCount(0);
            }
        }
        List<ValueAndNameVo> vo = new ArrayList<>();
        List<JobPublishModel> collect = jobPublishModels.stream().limit(10).collect(Collectors.toList());
        for (int i = 0; i < collect.size(); i++) {
            ValueAndNameVo vo0 = new ValueAndNameVo();
            for (int i1 = 0; i1 < jobPublishModels.size(); i1++) {
                if (collect.get(i).getJobType() != null) {
                    vo0.setId(i + 1);
                    if (collect.get(i).getJobType().equals(jobPublishModels.get(i1).getJobType())) {
                        vo0.setName(positionService.getModelById(jobPublishModels.get(i).getJobType()).getJobTitle());
                    }
                    vo0.setValue(collect.get(i).getCount());
                }
            }
            vo.add(vo0);
        }
        return Result.success(vo);
    }

    //就业行业统计
    @GetMapping("/supply")
    public Result<Object> supply() {
        List<JobIntentionModel> jobIntentionModels = jobIntentionService.selectPost();
        for (JobIntentionModel jobIntentionModel : jobIntentionModels) {
            if (jobIntentionModel.getCount() == null) {
                jobIntentionModel.setCount(0);
            }
        }
        List<ValueAndNameVo> vo = new ArrayList<>();
        List<JobIntentionModel> collect = jobIntentionModels.stream().limit(10).collect(Collectors.toList());
        for (int i = 0; i < collect.size(); i++) {
            if (collect.get(i).getPost() > 0) {
                PositionModel positionModel = positionMapper.selectById(collect.get(i).getPost());
                ValueAndNameVo vo0 = new ValueAndNameVo();
                vo0.setId(i + 1);
                if (positionModel != null) {
                    vo0.setName(positionModel.getJobTitle());
                }
                vo0.setValue(collect.get(i).getCount());
                vo.add(vo0);
            }
        }
        return Result.success(vo);
    }

    //各乡镇、街道就业排行
    @GetMapping("/employmentRanking")
    public Result<Object> employmentRanking() {
        List<ConfigModel> staticsTownCount = configMapper.getStaticsTownCount();
        List<ValueAndNameVo> vo = new ArrayList<>();
        for (int i = 0; i < staticsTownCount.size(); i++) {
            QueryWrapper<ConfigModel> queryWrapper = new QueryWrapper<>();
            ValueAndNameVo vo1 = new ValueAndNameVo();
            queryWrapper.select("name").eq("id", staticsTownCount.get(i).getFatherId());
            ConfigModel configModel = configMapper.selectOne(queryWrapper);
            if (configModel != null) {
                vo1.setName(configModel.getName());
            }
            vo1.setAllCount(staticsTownCount.get(i).getCount());
            vo1.setId(i + 1);
            vo.add(vo1);
        }
        return Result.success(vo);
    }




    //求职招聘
    //用人单位、在招岗位、全部岗位、求职人数、简历投递人、简历投递量
    @GetMapping("/selectEmploymentCount")
    public Result<Object> selectEmploymentCount() {
        Integer employersCount = enterpriseService.selectEmployersCount();
        Integer jobRecruitmentCount = jobPublishService.selectActivityThisMonthCount();
        Integer recruitmentCount = jobPublishService.selectRecruitmentCount();
        Integer seekersCount = customerService.selectSeekersCount();
        Integer resumeSubmitterCount = workApplyService.selectResumeSubmitterCount();
        Integer resumeSubmissionVolumeCount = workApplyService.selectResumeSubmissionVolumeCount();
        EmploymentVo vo = new EmploymentVo();
        vo.setEmployersCount(employersCount);
        vo.setJobRecruitmentCount(jobRecruitmentCount);
        vo.setRecruitmentCount(recruitmentCount);
        vo.setSeekersCount(seekersCount);
        vo.setResumeSubmitterCount(resumeSubmitterCount);
        vo.setResumeSubmissionVolumeCount(resumeSubmissionVolumeCount);
        return Result.success(vo);
    }



    //行业供求薪资分布 折线 平均期望薪资、平均岗位薪资
    @GetMapping("/avgSalary")
    public Result<Object> avgSalary() {
        return Result.success(jobIntentionService.avgSalary());
    }


    //动态帮扶分析
    //未就业⼈员性别、年龄分布
    @GetMapping("/employedPersonnel")
    public Result<Object> employedPersonnel() {
        IndexCountVo vo1 = (IndexCountVo) redisService.getStringKey("suzhouIndexCount");
        IndexCountVo vo2 = (IndexCountVo) redisService.getStringKey("jintaIndexCount");
        IndexCountVo vo3 = (IndexCountVo) redisService.getStringKey("dunhuangIndexCount");
//        IndexCountVo vo4 = (IndexCountVo) redisService.getStringKey("guazhouIndexCount");
//        IndexCountVo vo5 = (IndexCountVo) redisService.getStringKey("yumenIndexCount");
        IndexCountVo vo6 = (IndexCountVo) redisService.getStringKey("subeiIndexCount");
//        IndexCountVo vo7 = (IndexCountVo) redisService.getStringKey("akesaiIndexCount");
        Integer male = vo1.getMale() + vo2.getMale() + vo3.getMale() + vo6.getMale();
        Integer female = vo1.getFemale() + vo2.getFemale() + vo3.getFemale() + vo6.getFemale();
        double malePercent = (double) male / (male + female) * 100;
        double femalePercent = (double) female / (male + female) * 100;
        IndexCountVo vo = new IndexCountVo();
        vo.setMale(male);
        vo.setFemale(female);
        vo.setMalePercent(String.format("%.2f", malePercent));
        vo.setFemalePercent(String.format("%.2f", femalePercent));
        int[] agePercent1 = vo1.getAgePercent();
        int[] agePercent2 = vo2.getAgePercent();
        int[] agePercent3 = vo3.getAgePercent();
        int[] agePercent4 = {0, 0, 0, 0, 0, 0};
        int[] agePercent5 = {0, 0, 0, 0, 0, 0};
        int[] agePercent6 = vo6.getAgePercent();
        int[] agePercent7 = {0, 0, 0, 0, 0, 0};
        int allCount = agePercent1[5] + agePercent2[5] + agePercent3[5] + agePercent4[5] + agePercent5[5] + agePercent6[5] + agePercent7[5];
        int count1 = agePercent1[0] + agePercent2[0] + agePercent3[0] + agePercent4[0] + agePercent5[0] + agePercent6[0] + agePercent7[0];
        int count2 = agePercent1[1] + agePercent2[1] + agePercent3[1] + agePercent4[1] + agePercent5[1] + agePercent6[1] + agePercent7[1];
        int count3 = agePercent1[2] + agePercent2[2] + agePercent3[2] + agePercent4[2] + agePercent5[2] + agePercent6[2] + agePercent7[2];
        int count4 = agePercent1[3] + agePercent2[3] + agePercent3[3] + agePercent4[3] + agePercent5[3] + agePercent6[3] + agePercent7[3];
        int count5 = agePercent1[4] + agePercent2[4] + agePercent3[4] + agePercent4[4] + agePercent5[4] + agePercent6[4] + agePercent7[4];
        String format1 = String.format("%.2f", (double) count1 / allCount * 100);
        String format2 = String.format("%.2f", (double) count2 / allCount * 100);
        String format3 = String.format("%.2f", (double) count3 / allCount * 100);
        String format4 = String.format("%.2f", (double) count4 / allCount * 100);
        String format5 = String.format("%.2f", (double) count5 / allCount * 100);
        List<ValueAndNameVo> list = new ArrayList<>();
        ValueAndNameVo age1 = new ValueAndNameVo();
        age1.setName("20岁以下");
        age1.setPercent(format1);
        list.add(age1);
        ValueAndNameVo age2 = new ValueAndNameVo();
        age2.setName("20-30岁");
        age2.setPercent(format2);
        list.add(age2);
        ValueAndNameVo age3 = new ValueAndNameVo();
        age3.setName("30-40岁");
        age3.setPercent(format3);
        list.add(age3);
        ValueAndNameVo age4 = new ValueAndNameVo();
        age4.setName("40-50岁");
        age4.setPercent(format4);
        list.add(age4);
        ValueAndNameVo age5 = new ValueAndNameVo();
        age5.setName("50岁以上");
        age5.setPercent(format5);
        list.add(age5);
        vo.setAge(list);
        return Result.success(vo);
    }




    //⼈才学历分布
    @GetMapping("/talentEducation")
    public Result<Object> talentEducation() {
//        IndexCountVo vo1 = (IndexCountVo) redisService.getStringKey("suzhouIndexCount");
//        IndexCountVo vo2 = (IndexCountVo) redisService.getStringKey("jintaIndexCount");
//        IndexCountVo vo3 = (IndexCountVo) redisService.getStringKey("dunhuangIndexCount");
//        IndexCountVo vo4 = (IndexCountVo) redisService.getStringKey("guazhouIndexCount");
//        IndexCountVo vo5 = (IndexCountVo) redisService.getStringKey("yumenIndexCount");
//        IndexCountVo vo6 = (IndexCountVo) redisService.getStringKey("subeiIndexCount");
//        IndexCountVo vo7 = (IndexCountVo) redisService.getStringKey("akesaiIndexCount");
//        ValueAndNameVo educationPercent1 = vo1.getEducationPercent();
//        ValueAndNameVo educationPercent2 = vo2.getEducationPercent();
//        ValueAndNameVo educationPercent3 = vo3.getEducationPercent();
//        ValueAndNameVo educationPercent4 = vo4.getEducationPercent();
//        ValueAndNameVo educationPercent5 = vo5.getEducationPercent();
//        ValueAndNameVo educationPercent6 = vo6.getEducationPercent();
//        ValueAndNameVo educationPercent7 = vo7.getEducationPercent();
//        
//        int[] arr2 = educationPercent2.getArr();
//        int[] arr3 = educationPercent3.getArr();
//        int[] arr4 = educationPercent4.getArr();
//        int[] arr5 = educationPercent5.getArr();
//        int[] arr6 = educationPercent6.getArr();
//        int[] arr7 = educationPercent7.getArr();
        ValueAndNameVo educationPercent1 = cusEducationService.education();
        int[] arr1 = educationPercent1.getArr();
        Map<String, Integer> resultMap = new HashMap<>();
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(0).getData(), arr1[0]);
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(1).getData(), arr1[1]);
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(2).getData(), arr1[2]);
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(3).getData(), arr1[3]);
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(4).getData(), arr1[4]);
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(5).getData(), arr1[5]);
        resultMap.put(EducationTool.EDUCATION_VO_LIST.get(6).getData(), arr1[6]);
        List<ValueAndNameVo> vos = new ArrayList<>();
        ValueAndNameVo valueAndNameVo1 = new ValueAndNameVo();
        valueAndNameVo1.setValue(arr1[0]);
        valueAndNameVo1.setName(EducationTool.EDUCATION_VO_LIST.get(0).getData() + " " + valueAndNameVo1.getValue() + "人");
        vos.add(valueAndNameVo1);
        ValueAndNameVo valueAndNameVo2 = new ValueAndNameVo();
        valueAndNameVo2.setValue(arr1[1]);
        valueAndNameVo2.setName(EducationTool.EDUCATION_VO_LIST.get(1).getData() + " " + valueAndNameVo2.getValue() + "人");
        vos.add(valueAndNameVo2);
        ValueAndNameVo valueAndNameVo3 = new ValueAndNameVo();
        valueAndNameVo3.setValue(arr1[2]);
        valueAndNameVo3.setName(EducationTool.EDUCATION_VO_LIST.get(2).getData() + " " + valueAndNameVo3.getValue() + "人");
        vos.add(valueAndNameVo3);
        ValueAndNameVo valueAndNameVo4 = new ValueAndNameVo();
        valueAndNameVo4.setValue(arr1[3]);
        valueAndNameVo4.setName(EducationTool.EDUCATION_VO_LIST.get(3).getData() + " " + valueAndNameVo4.getValue() + "人");
        vos.add(valueAndNameVo4);
        ValueAndNameVo valueAndNameVo5 = new ValueAndNameVo();
        valueAndNameVo5.setValue(arr1[4]);
        valueAndNameVo5.setName(EducationTool.EDUCATION_VO_LIST.get(4).getData() + " " + valueAndNameVo5.getValue() + "人");
        vos.add(valueAndNameVo5);
        ValueAndNameVo valueAndNameVo6 = new ValueAndNameVo();
        valueAndNameVo6.setValue(arr1[5]);
        valueAndNameVo6.setName(EducationTool.EDUCATION_VO_LIST.get(5).getData() + " " + valueAndNameVo6.getValue() + "人");
        vos.add(valueAndNameVo6);
        ValueAndNameVo valueAndNameVo7 = new ValueAndNameVo();
        valueAndNameVo7.setValue(arr1[6]);
        valueAndNameVo7.setName(EducationTool.EDUCATION_VO_LIST.get(6).getData() + " " + valueAndNameVo7.getValue() + "人");
        vos.add(valueAndNameVo7);
        return Result.success(vos);
    }



    @GetMapping("/clickStatistics")
    public Result<Object> clickStatistics(Integer type) {//type = 1pc2小程序3触摸屏
        ClickStatisticsModel clickStatisticsModel = new ClickStatisticsModel();
        if (type != null && type == 1) {
            clickStatisticsModel.setType(type);
        }
        if (type != null && type == 2) {
            clickStatisticsModel.setType(type);
        }
        if (type != null && type == 3) {
            clickStatisticsModel.setType(type);
        }
        clickStatisticsModel.setCrtTime(CommonHelp.getNowTimestamp());
        clickStatisticsMapper.insert(clickStatisticsModel);
        return Result.success("记录成功");
    }



}
